﻿Public Class Project
    Implements IObject

    Private id As Integer
    Private name As String
    Private description As String
    Private estimatedFromDate As Date
    Private estimatedToDate As Date
    Private createDate As Date
    Private state As State
    Private projectResponsible As Resource
    Private projectMembers As ArrayList
    Private projectActivities As ArrayList

    Private projectState As ProjectState

    Public Sub setProjectState(ByRef projectState As ProjectState)
        Me.projectState = projectState
    End Sub

    Public Sub New()
        projectMembers = New ArrayList
        projectActivities = New ArrayList
        projectResponsibleProperty = New Resource
    End Sub

    Public Sub New(ByVal id As Integer)
        Me.id = id
        projectMembers = New ArrayList
        projectActivities = New ArrayList
    End Sub

    Public Sub New(ByVal id As Integer, ByVal name As String, ByVal description As String, ByVal estimatedFromDate As Date, ByVal estimatedToDate As Date, ByVal createDate As Date, ByRef state As State, ByVal projectResponsible As Resource)
        Me.id = id
        Me.name = name
        Me.description = description
        Me.estimatedFromDate = estimatedFromDate
        Me.estimatedToDate = estimatedToDate
        Me.createDate = createDate
        Me.state = state
        Me.projectResponsible = projectResponsible
        projectMembers = New ArrayList
        projectActivities = New ArrayList
    End Sub

    Public Property idProperty() As Integer
        Get
            Return Me.id
        End Get
        Set(ByVal value As Integer)
            Me.id = value
        End Set
    End Property

    Public Property nameProperty() As String
        Get
            Return Me.name
        End Get
        Set(ByVal value As String)
            Me.name = value
        End Set
    End Property

    Public Property descriptionProperty() As String
        Get
            Return Me.description
        End Get
        Set(ByVal value As String)
            Me.description = value
        End Set
    End Property

    Public Property estimatedFromDateProperty() As Date
        Get
            Return Me.estimatedFromDate
        End Get
        Set(ByVal value As Date)
            Me.estimatedFromDate = value
        End Set
    End Property

    Public Property estimatedToDateProperty() As Date
        Get
            Return Me.estimatedToDate
        End Get
        Set(ByVal value As Date)
            Me.estimatedToDate = value
        End Set
    End Property

    Public Property createDateProperty() As Date
        Get
            Return Me.createDate
        End Get
        Set(ByVal value As Date)
            Me.createDate = value
        End Set
    End Property

    Public Property stateProperty() As State
        Get
            Return Me.state
        End Get
        Set(ByVal value As State)
            Me.state = value
        End Set
    End Property

    Public Property projectResponsibleProperty() As Resource
        Get
            Return Me.projectResponsible
        End Get
        Set(ByVal value As Resource)
            Me.projectResponsible = value
        End Set
    End Property

    Public Property projectMembersProperty() As ArrayList
        Get
            Return Me.projectMembers
        End Get
        Set(ByVal value As ArrayList)
            Me.projectMembers = value
        End Set
    End Property

    Public Property projectActivitiesProperty() As ArrayList
        Get
            Return Me.projectActivities
        End Get
        Set(ByVal value As ArrayList)
            Me.projectActivities = value
        End Set
    End Property

    Public Function getTableName() As String Implements IObject.getTableName
        Return "PROJECTS"
    End Function

    Public Function getId() As Integer Implements IObject.getId
        Return id
    End Function

    Public Function getProjectState() As ProjectState
        Dim projectState As ProjectState = Nothing

        Select Case stateProperty.idProperty
            Case state.PROJECT_STATE_IN_PLANNING_ID
                projectState = New ProjectStateInPlanning
            Case state.PROJECT_STATE_IN_PROCESS_ID
                projectState = New ProjectStateInProcess
            Case state.PROJECT_STATE_COMPLETED_ID
                projectState = New ProjectStateCompleted
            Case state.PROJECT_STATE_CANCEL_ID
                projectState = New ProjectStateCancel
        End Select

        Return projectState
    End Function
End Class
